<?php
/**
 * This file is part of the Agora distribution. 
 * Detailed copyright and licensing information can be found
 * in the gpl-3.0.txt file which should be included in the distribution.
 * 
 * @version		$Id: 3.0.14 Olympus 2010-09-28 rammstein4o $
 * @copyright  2007 - 2010 jVitals
 * @license   GPLv3 Open Source
 * @link       http://jvitals.com
 * @since      File available since initial release
 */	
	defined ('IN_AGORA') or die;

	class AdSenseModel extends Model
	{
		function __construct()
		{
			parent::__construct('adsense_config');
		}

		function load()
		{
			$sql = "SELECT conf_name,conf_value FROM {$this->table}";
			$this->db->setQuery($sql);
			$list = $this->db->loadRowList();
			if (!$list) return false;
			$data = array();
			foreach ($list as $result) {
				$fname = $result[0];
				$fvalue = $result[1];
				$data[$fname] = $fvalue;
			}
			return $data;
		}
	
	    function save($data)
	    {
	    	foreach ($data as $key => $value) {
	    		$this->db->setQuery('UPDATE ##__adsense_config SET conf_value = '.$this->db->Quote($value).' WHERE conf_name = '.$this->db->Quote($key));
	    		if (!$this->db->query()) {
	    			print $this->db->getErrorMsg();
	    			die;
	    		}
	    	}
	    }
	}
?>